import ajax from '../service/ajax.js'

export default{
    namespaced:true,
    state:{
        areaList:{},
        areaParam:{pageNo:'1',pageSize:'',areaName:'',areaSeed:'',className:''},
        classList:{},
        classParam:{pageNo:'1',pageSize:'',className:'',areaName:''},
        eventList:{},
        eventParam:{pageNo:'1',pageSize:'',eventName:'',eventStage:'',areaName:'',startTime:'',endTime:''},
    },
    mutations:{
        setAreaList(state,area){
            state.areaList = area
        },
        setAreaParam(state,area){
            state.areaParam = area
        },
        setClassList(state,classs){
            state.classList = classs
        },
        setClassParam(state,classs){
            state.classParam = classs
        },
        setEventList(state,event){
            state.eventList = event
        },
        setEventParam(state,event){
            state.eventParam = event
        }

    },
    actions:{
        async findAllArea(context){
            let areaInfo = await ajax.getSubmit("/api/area/findAllArea",context.state.areaParam)
            context.commit("setAreaList",areaInfo)
            console.log(areaInfo)
            console.log(context.state.areaList)
        },
        async findAreaName(context){
            let areaInfo = await ajax.getSubmit("/api/area/findName",context.state.areaParam)
            context.commit("setAreaList",areaInfo)
            console.log(areaInfo)
            console.log(context.state.areaList)
        },
        async findAllClass(context){
            let classInfo = await ajax.getSubmit("/api/class/findAllClass",context.state.classParam)
            context.commit("setClassList",classInfo)
            console.log(classInfo)
            console.log(context.state.classList)
        },
        async findClassName(context){
            let classInfo = await ajax.getSubmit("/api/class/findName",context.state.classParam)
            context.commit("setClassList",classInfo)
            console.log(classInfo)
            console.log(context.state.classList)
        },
        async findAllEvent(context){
            let eventInfo = await ajax.getSubmit("/api/event/findAllEvent",context.state.eventParam)
            context.commit("setEventList",eventInfo)
            console.log(eventInfo)
            console.log(context.state.eventList)
        },
        async findEventName(context){
            let eventInfo = await ajax.getSubmit("/api/event/findName",context.state.eventParam)
            context.commit("setEventList",eventInfo)
            console.log(eventInfo)
            console.log(context.state.eventList)
        }
    }
}